package web.member;

import com.google.gson.Gson;
import entity.MemberBean;
import services.MemberServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/searchMemberByPhone")
public class GetMemberByPhone extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String member_phone = req.getParameter("member_phone");
        // 先判断该会员是否为启用
        MemberBean memberBeans = new MemberServices().getMemberByPhone(member_phone);
        if("禁用".equals(memberBeans.getMember_state())){
            resp.getWriter().println("{\"result\":\"禁用\"");
            return;
        }
        Gson gson = new Gson();
        String json = gson.toJson(memberBeans);
        resp.getWriter().println(json);
    }
}
